from lxml import etree
str =  '<bookstore>' \
            '<book>' \
                '<title lang="bng" src="https://www.baidu.com">Harry Potter</title>' \
                '<price>29.99</price>' \
            '</book>' \
            '<book>' \
                '<title class="t1" lang="ang">Learning XML</title>' \
                '<price>39.95</price>' \
            '</book>' \
            '<book>' \
                '<title lang="cng">西游记</title>' \
                '<price>69.95</price>' \
            '</book>' \
            '<book>' \
                '<title lang="dng" src="https://www.jd.com">水浒传</title>' \
                '<price>29.95</price>' \
            '</book>' \
            '<book>' \
                '<title class="t1" lang="dng" src="https://www.jd.com">三国演义</title>' \
                '<price>29.95</price>' \
            '</book>' \
        '</bookstore>'
html=etree.HTML(str)

bookstore = html.xpath('/html/body/bookstore')
title = html.xpath('//book/title/text()')
print(title)
